import request from '@/utils/request'

// 查询设备状态变更日志列表
export function listStatusLogs(query) {
  return request({
    url: '/ldzl-sb/sb/status/log/list',
    method: 'get',
    params: query
  })
}

// 查询设备状态变更日志详细
export function getStatusLog(logId) {
  return request({
    url: '/ldzl-sb/sb/status/log/' + logId,
    method: 'get'
  })
}

// 查询指定设备的状态变更日志列表
export function listEquipmentStatusLogs(equipmentId) {
  return request({
    url: '/ldzl-sb/sb/status/log/equipment/' + equipmentId,
    method: 'get'
  })
}

// 变更设备状态
export function changeEquipmentStatus(equipmentId, status, reason) {
  const data = {
    equipmentId: equipmentId,
    status: status,
    reason: reason
  }
  return request({
    url: '/ldzl-sb/sb/equipment/status',
    method: 'put',
    data: data
  })
}

// 获取设备状态统计信息
export function getEquipmentStatusStats() {
  return request({
    url: '/ldzl-sb/sb/status/log/statistics',
    method: 'get'
  })
}

// 获取年度设备状态变更统计
export function getYearlyStatusChanges(year) {
  return request({
    url: '/ldzl-sb/sb/status/log/yearly-changes',
    method: 'get',
    params: { year }
  })
} 